package com.dormms.www.contact.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dormms.www.contact.mapper.ContactMapper;
import com.dormms.www.contact.service.ContactService;
import com.dormms.www.dto.PageQueryObject;
import com.dormms.www.entity.Contacts;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;

@Service
public class ContactServiceImpl extends ServiceImpl<ContactMapper, Contacts> implements ContactService {

    @Resource
    private ContactMapper contactMapper;

    @Override
    public Page<Contacts> contactsSelectPage(PageQueryObject pageQueryObject) {
        //初始化page对象
        Page<Contacts> p = new Page<>(pageQueryObject.getPageNumber(), pageQueryObject.getPageSize());
        //初始化筛选条件
        QueryWrapper<Contacts> w = new QueryWrapper<>();
        return this.page(p, w);
    }

    @Override
    public boolean addContact(Contacts addContact) {
        return this.save(addContact);
    }

    @Override
    public boolean updateContact(Contacts updateContact) {
        return this.updateById(updateContact);
    }
}
